function get_gmaps(oParams, sHeaderId) {
	oParams = oParams || {};
	sHeaderId = sHeaderId || 'gmaps_view_navigation';
	
	set_header_text(sHeaderId);
	
	create_el_overlay($('#gmaps_dyn_table'), null, function(sId, oImg, oParams) {
		$.post('/admin/gmaps_ajax/get_gmaps_json', oParams, function(data) {
			$('#gmaps_dyn_table').children('tbody').html('').html(data.sContent);
			$(oImg).remove();
			$('#' + sId).remove();
		}, 'json');
	}, oParams);
}


function set_header_text(sId) {
	if ($('#' + sId).hasClass('gmaps_view_header_on') === false) {
		$('.gmaps_view_header_on').removeClass('gmaps_view_header_on').fadeOut(500, function() {
			$('#' + sId).addClass('gmaps_view_header_on').fadeIn(500);
		});
	}
}


$(document).ready(
	function() {
		get_gmaps();
		
		
		$('#gmaps_search_button').bind('click', function() {
			var oParams = {};
			
			oParams.sSearchText = $('#search_text').val();
			oParams.iSearchSite = $('#search_site').val();
			
			if ((val_is_empty(oParams.sSearchText) === true) && (val_is_empty(oParams.sSearchUrl) === true)) {
				$.prompt('<?php echo addslashes($aMessages['admin_search_no_criteria']); ?>');
				return;
			}
			
			set_header_text('gmaps_view_search');
			
			create_el_overlay($('#gmaps_dyn_table'), null, function(sId, oImg, oParams) {
				$.post('/admin/gmaps_ajax/search_gmaps', oParams, function(data) {
					$('#gmaps_dyn_table').children('tbody:first').html('').html(data.sContent);
					$(oImg).remove();
					$('#' + sId).remove();
				}, 'json');
			}, oParams);
			
		});
	}
);